var crypto = require('crypto');
var key = '12345678';
exports.des = {

    algorithm:{  ecb:'des-ecb',cbc:'des-cbc'  },
    encrypt:function(plaintext){
        var key = new Buffer("12345678");
        var iv = new Buffer("12345678");
        var cipher = crypto.createCipheriv(this.algorithm.cbc, key, iv);
        cipher.setAutoPadding(true)  //default true
        var ciph = cipher.update(plaintext, 'utf8', 'base64');
        ciph += cipher.final('base64');
        return ciph;
    },
    decrypt:function(encrypt_text){
        var key = new Buffer("12345678");
        var iv = new Buffer("12345678");
        var decipher = crypto.createDecipheriv(this.algorithm.cbc, key, iv);
        decipher.setAutoPadding(true);
        var txt = decipher.update(decodeURIComponent(encrypt_text), 'base64', 'utf8');
        txt += decipher.final('utf8');
        return txt;
    }

};